package com.ruoyi.web.controller.system;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSON;
import com.ruoyi.system.domain.ExpertDataVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ExpertScoring;
import com.ruoyi.system.service.IExpertScoringService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 专家评分Controller
 * 
 * @author ruoyi
 * @date 2025-05-13
 */
@Controller
@RequestMapping("/system/scoring")
public class ExpertScoringController extends BaseController
{
    private String prefix = "system/scoring";

    @Autowired
    private IExpertScoringService expertScoringService;

    @RequiresPermissions("system:scoring:view")
    @GetMapping()
    public String scoring()
    {
        return prefix + "/scoring";
    }

    /**
     * 查询专家评分列表
     */

    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ExpertScoring expertScoring)
    {
        startPage();
        List<ExpertScoring> list = expertScoringService.selectExpertScoringList(expertScoring);
        return getDataTable(list);
    }

    /**
     * 导出专家评分列表
     */

    @Log(title = "专家评分", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ExpertScoring expertScoring)
    {
        List<ExpertScoring> list = expertScoringService.selectExpertScoringList(expertScoring);
        ExcelUtil<ExpertScoring> util = new ExcelUtil<ExpertScoring>(ExpertScoring.class);
        return util.exportExcel(list, "专家评分数据");
    }

//    /**
//     * 新增专家评分
//     */
//    @RequiresPermissions("system:scoring:add")
//    @GetMapping("/add")
//    public String add()
//    {
//        return prefix + "/add";
//    }
    /**
     * 新增专家评分
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存专家评分
     */
    @Log(title = "专家评分", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ExpertDataVo vo)
    {
        return toAjax(expertScoringService.insertData(vo));
    }

    /**
     * 修改专家评分
     */

    @GetMapping("/edit/{expertId}")
    public String edit(@PathVariable("expertId") Long expertId, ModelMap mmap)
    {
        ExpertScoring expertScoring = expertScoringService.selectExpertScoringByExpertId(expertId);
        mmap.put("expertScoring", expertScoring);
        mmap.put("expertId", expertId);
        return prefix + "/edit";
    }

    /**
     * 修改保存专家评分
     */

    @Log(title = "专家评分", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ExpertScoring expertScoring)
    {
        return toAjax(expertScoringService.updateExpertScoring(expertScoring));
    }

    /**
     * 删除专家评分
     */

    @Log(title = "专家评分", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(expertScoringService.deleteExpertScoringByExpertIds(ids));
    }
}
